package io.renren.modules.jxgk.controller;

import io.renren.common.annotation.SysLog;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import io.renren.modules.jxgk.entity.ProfessionInfoEntity;
import io.renren.modules.jxgk.service.ProfessionInfoService;
import io.renren.modules.jxgkphone.tempEntity.TempStudentAttendence;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.wuwenze.poi.ExcelKit;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("ProfessionInfo/")
public class ProfessionInfoController {

    @Autowired
    ProfessionInfoService professionInfoService;

    @RequestMapping("Select")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<ProfessionInfoEntity> cse = professionInfoService.queryList(query);
        int total = professionInfoService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(cse, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }
    @RequestMapping("/Delete")
    public R delete(@RequestBody String[] indexs){
        professionInfoService.deleteBatch(indexs);
        return R.ok();
    }
    @RequestMapping("/Insert")
    public R save(@RequestBody ProfessionInfoEntity ste){
        professionInfoService.save(ste);
        return R.ok();
    }
    @RequestMapping("/Info/{index}")
    public R info(@PathVariable("index") String index){
        ProfessionInfoEntity cse = professionInfoService.queryObject(index);
        return R.ok().put("ProfessionInfo", cse);
    }
    @SysLog("修改用户")
    @RequestMapping("/Update")
    public R update(@RequestBody ProfessionInfoEntity cse){
        professionInfoService.update(cse);
        return R.ok();
    }
    @RequestMapping("/export")
    public R export(HttpServletResponse response,@RequestParam Map<String, Object> params ) {
        List<ProfessionInfoEntity> cse = null;
        try{
            cse=cse = professionInfoService.queryList(params);
            ExcelKit.$Export(ProfessionInfoEntity.class, response).toExcel(cse, "专业信息汇总");
        }catch (Exception e)
        {
            e.printStackTrace();
        }
        return R.ok();
    }

}